<template>
  <!--  已处理-->
  <div class="processedVehicle">
    <el-card shadow="never" style="margin-top: 30px">
      <div class="header">
        <div class="page-header">
          <el-page-header @back="goBack" content="已处理车辆" style="margin-bottom: 20px">
          </el-page-header>
        </div>
      </div>

      <el-table
          :data="vehicleTable"
          style="width: 100%"
          highlight-current-row
          stripe
      >
        <el-table-column
            label="序号"
            type="index"
            width="50"
            :index="indexMethod">
        </el-table-column>
        <el-table-column
            prop="veName"
            label="车主姓名"
        >
        </el-table-column>
        <el-table-column
            prop="veNumber"
            label="车牌号"
        >
        </el-table-column>
        <el-table-column
            prop="veType"
            label="业务类型"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.veType == 1">免费</span>
            <span v-else>月租</span>
          </template>
        </el-table-column>
        <el-table-column
            prop="approTime"
            label="审核时间"
            sortable>
          <template slot-scope="scope">
            {{shortTime(scope.row.approTime)}}
          </template>
        </el-table-column>
        <el-table-column
            prop="approStatus"
            label="审核结果"
            :filters="[{ text: '通过', value: 1 }, { text: '不通过', value: 0 }]"
            :filter-method="filterTag"
            filter-placement="bottom-end">
          <template slot-scope="scope">
            <span v-if="scope.row.approStatus == 1"><el-tag type="success" size="small" color="">通过</el-tag></span>
            <span v-else><el-tag type="danger" size="small" color="">不通过</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column
            prop="approNote"
            label="审核备注"
        >
        </el-table-column>
        <el-table-column
            label="操作"
            width="100">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="toVehicleDetail(scope.row.veApproId)">详情</el-button>
          </template>
        </el-table-column>
      </el-table>


      <div style="padding: 10px 0">
        <el-pagination
            :page-sizes="[2, 5, 10, 20]"
            :page-size=this.pageSize
            layout="total, sizes, prev, pager, next, jumper"
            :total=this.total
            :current-page=this.pageNum
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
        >
        </el-pagination>
      </div>

    </el-card>
  </div>
</template>

<script>
import {getVehicleApplyByPagePass} from "@/api/allApi";
import {shortTime} from "../../../../utils/timeFormat";

export default {
  name: "PendingFeedback",
  data(){
    return{
      vehicleTable:[],
      pageSize:5,
      total:0,
      pageNum:1,
    }
  },
  methods:{
    shortTime,
    goBack() {
      this.$router.back();
    },
    filterTag(value, row) {
      return row.approStatus === value;
    },
    indexMethod(index) {
      // 当前页数 - 1 * 每页数据条数 + 1
      const page = this.pageNum // 当前页码
      const pagesize = this.pageSize // 每页条数
      return index + 1 + (page - 1) * pagesize
    },
    handleSizeChange(pageSize){
      this.pageSize=pageSize;
      this.getVehicleApplyByPagePass();
    },
    handleCurrentChange(pageNum){
      this.pageNum=pageNum;
      this.getVehicleApplyByPagePass();
    },
    getVehicleApplyByPagePass() {
      getVehicleApplyByPagePass({
        current:this.pageNum,
        pageSize:this.pageSize
      }).then(res=>{
        this.vehicleTable = res.data.data
        this.total = res.data.total
      })
    },

    toVehicleDetail(veApproId) {
      this.$router.push({
        path: "/adminLayout/adminBackground/vehicleDetailUser/"+veApproId,
      });
    }
  },
  mounted() {
    this.getVehicleApplyByPagePass()
  }
}
</script>

<style lang="less" scoped>
.vehicleForm {
  width: 800px;
  padding: 30px;

}
</style>